package com.bw.a1908.ui.video;

import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import com.bw.a1908.R;
import com.bw.a1908.adapter.VideoCardAdapter;
import com.bw.a1908.adapter.VideoCardDecoration;
import com.bw.a1908.bean.VideoBean;
import com.bw.a1908.contract.VideoContract;
import com.bw.a1908.core.mvp.BaseFragment;
import com.bw.a1908.presenter.VideoPresenter;

import java.util.List;

public class CardVideoFragment extends BaseFragment<VideoPresenter> implements VideoContract.View {

    private RecyclerView recyclerView;
    private VideoCardAdapter mAdapter;

    @Override
    public void initAdapter(List<VideoBean> videoBeans) {
        if (mAdapter == null) {
            mAdapter = new VideoCardAdapter(videoBeans);
            recyclerView.setAdapter(mAdapter);
        }
    }

    @Override
    public int bandLayout() {
        return R.layout.fragment_video_card_list;
    }

    @Override
    public void initView() {
        recyclerView = findViewById(R.id.fragment_video_rv);
        recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
        recyclerView.addItemDecoration(new VideoCardDecoration(getContext()));
    }

    @Override
    public void initData() {
        mPresenter = new VideoPresenter(this);
        mPresenter.list();
    }
}
